#ifndef SMS_DEBUG_H
#define SMS_DEBUG_H

#include <glib.h>


G_BEGIN_DECLS


#define LOG_MSG(level, rc, pfargs)              \
   G_STMT_START {                               \
      char *_s = g_strdup_printf pfargs;        \
      g_log(G_LOG_DOMAIN, level, "%s", _s);     \
      g_free(_s);                               \
   } G_STMT_END


#define LCRITICAL(rc, s) LOG_MSG(G_LOG_LEVEL_CRITICAL, rc, s)
#define LERROR(rc, s)    LOG_MSG(G_LOG_LEVEL_WARNING, rc, s)
#define LINFO(rc, s)     LOG_MSG(G_LOG_LEVEL_INFO, rc, s)
#define LDEBUG(rc, s)    LOG_MSG(G_LOG_LEVEL_DEBUG, rc, s)


#define ENTRY_RECURSIVE
#define EXIT_RECURSIVE       return
#define RETURN_RECURSIVE(rc) return (rc)
#define ENTRY
#define EXIT                 return
#define RETURN(rc)           return (rc)
#define GOTO(rc, _l)         goto _l
#define CASE(_e)             case _e:


#define CASE_RETURN_STR(_v) case _v: return #_v


gboolean debug_open_log(void);
const char *debug_get_log_path(void);
G_END_DECLS


#endif
